home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
098
/
parint.lbr
/
parint.asm
next >
Wrap
Assembly Source File
|
2011-02-02
|
7KB
|
200 lines
comment * parint.asm - (c) David G. Hunter
keyed by Howard Ekman
Terrapin Station 612 623 1156
This program may be freely copied but not sold for profit.
PARINT.COM detects parity errors, logs them on the printer if
possible, beeps, and returns to program execution. The system does
not halt when this program is resident. Parity error checking is
supressed after the first parity error is detected. The error
message includes the time of the event. If the printer is not
available, the errors are logged to the screen.
*
;******************* Address of Interupt Handlers *********************
Book segment at 0h ; This is where the interrupt address book is
org 2h*4 ;
Int_2 label dword ; Address of NMI handler
Book ends
;***************** Beginning of Parint Instructions ******************
cseg segment
assume cs:cseg
org 100h
start: jmp newvec ; install new NMI handler in RAM
;*************************** NMI handler ******************************
newint proc near ; New interrupt handler
assume ds:cseg, es:cseg
sti ; This flag was cleared when interrupt was issued
jmp go ; Jump over more data
;**************************** D A T A ******************************
GetOut: nop
Instruc db 0EAh
Oldint dd
Device1 dw 0004
Device2 dw 0001
par1 db 0Dh,0Ah,"Parity Error: Main Board ",07h,0Dh,0Ah
par2 db 0Dh,0Ah,"Parity Error: Expansion Board",07h,0Dh,0Ah
time db " TIME: "
hour dw "00"
db ":"
min dw "00"
db " ",0Dh,0Ah
paroff db "PARITY CHECKING NOW DISABLED ",0dH,0Ah,0Ah
go: push cx
push ds
pushf
push dx
push bx
push ax
pushf
mov al,00h ; Turn off parity checking for now
out 0A0h,al ; CX = error flag: CX = 1 if parity OK
xor cx,cx ; get data in port C
; - - - - - - Find origin of NMI - - - - - - -
in al,62h
test al,40h
jz mother
mov dx,offset par2 ; If bit 6 is set, error is on expansion board
jmp out ; print message and exit
mother: test al,80h
jz other
mov dx,offset par1 ; If bit 7 is set, error on main board
jmp out ; print message and exit
other: or cx,1h ; If neither bit is set, no parity error occurred
mov al,80h ; So set parity flag OK,
out 0A0h,al ; Turn parity checking back on.
jmp noprt ; Dont print message if no parity error
;- - Print error messages and exit, Type of exit depends on error - - - - -
out: mov ax,cs ; Establish proper data segment to
mov ds,ax ; allow access to message
call whatime ; Get time of error
mov bx,device1
cmp bx,0004 ; If output is to printer, make sure it's ready
jne f1
call testprt
f1: call print
mov dx,offset time ; Time of error message
call print
mov dx,offset paroff
call print
noprt: popf
pop ax
pop bx
pop dx
popf
pop ds
test cx,1h ; special exit if parity OK.
jnz oth
pop cx ; Message printed, continue other program continue
iret
; If no parity error, turn control over to pre-exitsting NMI handler. This is
; done by restoring the DS registre and jmuping to the instruction that specifi
; es the address of the old interrupt routine. This unnusual exit is necessary
; because once the DS is restored the address of the old interrupt would be
; inaccessable.
oth: cli
pop cx
jmp GetOut
newint endp
;************** Subroutines ****************************
Testprt proc near
push dx
push ax
xor dx,dx ; pronter #0
mov ah,2
int 17h ; read printer status
test ah,00101001b ; error bits
jz aok
mov bx,device2 ; if not OK, try other device
aok: pop ax
pop dx
ret
testprt endp
Print proc near ; Ooutput to file named in BX, if error try another file
push cx
mov cx,34 ; 34 characters to print
mov ah,40h ; DOS function call
int 21h
pop cx
ret
print endp
Whatime proc near ; What time is it? Put results in Hours/Minutes.
push cx
push dx
mov ah,2Ch ; DOS time
int 21h
mov al,ch ; hours (0-23)
call convt ; Put tens in AH, ones in AL
mov hour,"00"
add hour,ax
mov al,cl
call convt ; Do the same for minutes
mov min,"00"
add min,ax
pop dx
pop cx
ret
whatime endp
Convt proc near ; convert number (<100) to ASCII. Number is in AL
xor ah,ah ; Result: Tens in AH, ones in AL.
xor ah,ah ; input is less than 100 anyway - clear it.
push cx
mov cl,10
div cl ; divide by ten
pop cx
little: ret
convt endp
;********************* Install NMI handler ********************
Newvec proc near
jmp past
loaded db 0Dh,0Ah,"Parity Error Intercetor v2.00 "
db "by David Hunter IS NOW"
db " INSTALLED",0Dh,0Ah,"$"
past: mov dx, offset loaded
mov ah,9
int 21h
assume ds:Book ; interrupt address book area
push ds ; save old DS for future use.
mov ax,Book
mov ds,ax
mov al,00h
out 0A0h,al ; turn off parity checking
mov ax,int_2 ; get the address
mov oldint,ax ; save it for some future use
mov ax,int_2[2] ; second part of double word
mov oldint[2],ax
mov int_2, offset newint ; now load the new address
mov int_2[2],cs ; CS is DS in .COM program
mov al,80h
out 0A0h,al ; turn parity checking back on
mov dx, offset newvec ; leave new interrupt routine resident
int 27h ; don't need NEWVEC or beyond
newvec endp
cseg ends
end start